<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/common/inc/incSession.jsp" %>
<jsp:include page="/common/inc/Top.jsp" />

<%
	String event_type = util.getStr(request.getParameter("event_type"));
	// paging
	String perRow 		= util.getStr(request.getParameter("perRow"));
	String startRow 	= util.getStr(request.getParameter("startRow"));
	String currentPage 	= util.getStr(request.getParameter("currentPage"));
	
	perRow = "".equals(perRow) ?"16":perRow;
	startRow = "".equals(startRow)?"0":startRow;
	currentPage = "".equals(currentPage)?"1":currentPage;
	
	param.put("event_type", event_type);
	
	// paging
	param.put("perRow", perRow);
	param.put("startRow", startRow);
	
	ArrayList rs =	(ArrayList)sqlMap.queryForList("Event.selectEventMain",param);	//	실행할 SQL ID, 검색조건(없을경우 null)
	HashMap map	 = 	(HashMap)sqlMap.queryForObject("Event.selectEventMainCount",param);	//	실행할 SQL ID, 검색조건(없을경우 null)
	
%>

<script>
	$(document).ready(function() {
		
		$("tr[name^='view']").click(function(){
			$('#event_id').val($(this).attr("event_id"));
			$('#status').val($(this).attr("status"));
	    	$("#eventMain").attr("action","/event/eventDetail.jsp");
	    	$("#eventMain").attr("method","post");
			$("#eventMain").submit();
		});
		
	});
	
</script>

<body>

<form id="eventMain">
	<input type="hidden" id="event_id" name="event_id" />
	<input type="hidden" id="status" name="status" />
	<table border="1">
	<tr>
		<td>이미지</td>
		<td>이벤트명</td>
		<td>모집시작일</td>
		<td>모집종료일</td>
		<td>리뷰등록시작일</td>
		<td>리뷰등록종료일</td>
		<td>상태</td>
<% 		
	for( int i = 0 ; i < rs.size() ; i++){
		String event_id = util.getStr(((HashMap)rs.get(i)).get("event_id"));
		String status = util.getStr(((HashMap)rs.get(i)).get("status"));
		if(status.equals("request")){
			status = "모집중";
		}else if(status.equals("end")){
			status = "응모마감";
		}else if(status.equals("review")){
			status = "리뷰보기";
		}
		 
%>
    <tr name="view" event_id="<%= event_id  %>" status="<%= util.getStr(((HashMap)rs.get(i)).get("status")) %>">
	    <td><img src="/<%= util.getStr(((HashMap)rs.get(i)).get("thumb_img")) %>" style="width: 30px; height: 30px;" ></td>
	    <td><%= util.getStr(((HashMap)rs.get(i)).get("event_name")) %></td>
	    <td><%= util.getStr(((HashMap)rs.get(i)).get("req_fdate")) %></td>
	    <td><%= util.getStr(((HashMap)rs.get(i)).get("req_tdate")) %></td>
	    <td><%= util.getStr(((HashMap)rs.get(i)).get("review_fdate")) %></td>
	    <td><%= util.getStr(((HashMap)rs.get(i)).get("review_tdate")) %></td>
	    <td><%= status %></td>
    </tr>
<%  } %>
 	
 	</table>		
</form>	
	
</body>
</html>